package com.zjsd.sqeybusiness.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.zjsd.sqeybusiness.domain.Jobplan;
import com.zjsd.sqeybusiness.service.IJobplanService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 工作计划Controller
 *
 * @author Zheng
 * @date 2022-06-23
 */
@RestController
@RequestMapping("/sqeybusiness/jobplan")
public class JobplanController extends BaseController
{
    @Autowired
    private IJobplanService jobplanService;

    /**
     * 查询工作计划列表
     */
    //@PreAuthorize("@ss.hasPermi('sqeybusiness:jobplan:list')")
    @GetMapping("/list")
    public TableDataInfo list(Jobplan jobplan)
    {
        startPage();
        List<Jobplan> list = jobplanService.selectJobplanList(jobplan);
        return getDataTable(list);
    }

    /**
     * 导出工作计划列表
     */
    //@PreAuthorize("@ss.hasPermi('sqeybusiness:jobplan:export')")
    //@Log(title = "工作计划", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Jobplan jobplan)
    {
        List<Jobplan> list = jobplanService.selectJobplanList(jobplan);
        ExcelUtil<Jobplan> util = new ExcelUtil<Jobplan>(Jobplan.class);
        return util.exportExcel(list, "jobplan");
    }

    /**
     * 获取工作计划详细信息
     */
    //@PreAuthorize("@ss.hasPermi('sqeybusiness:jobplan:query')")
    @GetMapping(value = "/{planid}")
    public AjaxResult getInfo(@PathVariable("planid") Long planid)
    {
        return AjaxResult.success(jobplanService.selectJobplanById(planid));
    }

    /**
     * 新增工作计划
     */
    //@PreAuthorize("@ss.hasPermi('sqeybusiness:jobplan:add')")
    //@Log(title = "工作计划", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Jobplan jobplan)
    {
        return toAjax(jobplanService.insertJobplan(jobplan));
    }

    /**
     * 修改工作计划
     */
    //@PreAuthorize("@ss.hasPermi('sqeybusiness:jobplan:edit')")
    //@Log(title = "工作计划", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Jobplan jobplan)
    {
        return toAjax(jobplanService.updateJobplan(jobplan));
    }

    /**
     * 删除工作计划
     */
    //@PreAuthorize("@ss.hasPermi('sqeybusiness:jobplan:remove')")
    //@Log(title = "工作计划", businessType = BusinessType.DELETE)
	@DeleteMapping("/{planids}")
    public AjaxResult remove(@PathVariable Long[] planids)
    {
        return toAjax(jobplanService.deleteJobplanByIds(planids));
    }
}
